import request from './index.js'
import { API_CONFIG } from '../config/api.js'

// 农场土地相关API
export const farmApi = {
    // 获取用户仓库内容
    getUserProductStore(params) {
        return request({
            url: API_CONFIG.ENDPOINTS.FARM.PRODUCT,
            method: 'GET',
            data: params
        })
    },
    // 获取土地信息列表 GET /user/land
    getLandList() {
        return request({
            url: API_CONFIG.ENDPOINTS.FARM.LAND_LIST,
            method: 'GET'
        })
    },

    // 用户播种操作 POST /user/land/seeding { landId, seedId }
    seeding(data) {
        return request({
            url: API_CONFIG.ENDPOINTS.FARM.LAND_SEEDING,
            method: 'POST',
            data
        })
    },

    // 用户收获果实 POST /user/land/win { landId }
    harvest(data) {
        return request({
            url: API_CONFIG.ENDPOINTS.FARM.LAND_HARVEST,
            method: 'POST',
            data
        })
    },

    // 获取土地操作信息 GET /user/land/operate_list
    getLandOperateList() {
        return request({
            url: API_CONFIG.ENDPOINTS.FARM.LAND_OPERATE_LIST,
            method: 'GET'
        })
    },

    // 用户道具对土地操作 POST /user/land/operate { landId, type, whId, itemId }
    landOperate(data) {
        return request({
            url: API_CONFIG.ENDPOINTS.FARM.LAND_OPERATE,
            method: 'POST',
            data
        })
    },

    // 获取背包列表 GET /user/knapsack ?type&page&limit
    getKnapsack(params) {
        return request({
            url: API_CONFIG.ENDPOINTS.FARM.KNAPSACK,
            method: 'GET',
            data: params
        })
    },

    // 出售收获的果实 POST /user/pay-harvest { num, seedId }
    payHarvest(data) {
        return request({
            url: API_CONFIG.ENDPOINTS.FARM.PAY_HARVEST,
            method: 'POST',
            data
        })
    },

    // 获取果实出售记录 GET /user/pay-harvest-log
    getPayHarvestLog() {
        return request({
            url: API_CONFIG.ENDPOINTS.FARM.PAY_HARVEST_LOG,
            method: 'GET'
        })
    },

    // 获取升级材料配置 GET /user/warehouse-upgrade-materials 0:种子; 1:升级材料; 2:道具;
    getUpgradeMaterial(type) {
        return request({
            url: API_CONFIG.ENDPOINTS.FARM.UPGRADE_MATERIAL + '?type=' + type,
            method: 'GET'
        })
    },

    // 升级仓库 POST /user/upgrade-storehouse
    upgradeStorehouse() {
        return request({
            url: API_CONFIG.ENDPOINTS.FARM.UPGRADE_STOREHOUSE,
            method: 'POST'
        })
    },

    // 授权信息上传 POST /user/auth-permissions
    authPermissions(data) {
        return request({
            url: '/user/auth-permissions',
            method: 'POST',
            data
        })
    }
}